Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix playing backwards discrete animation will begin with the first keyframe #92846

Closed
wants to merge 1 commit into from

Conversation

Nazarwadim
Copy link
Contributor

This seems to fix #92840

@Nazarwadim Nazarwadim requested a review from a team as a code owner June 6, 2024 18:49
Copy link
Member

@TokageItLab TokageItLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an incorrect fix.

I found some problems in the AnimationMixer, but the main cause for this issue is that the AnimationPlayerEditor is unintentionally seeking to position 0 immediately after playback; Somehow pressing the play button causes the seek to occur three times, but it should only be once.

@Nazarwadim
Copy link
Contributor Author

Nazarwadim commented Jun 7, 2024

I found the problem here.

if (seeked) {
int idx = a->track_find_key(i, time, is_external_seeking ? Animation::FIND_MODE_NEAREST : Animation::FIND_MODE_EXACT, true);
if (idx < 0) {
continue;
}
t->use_discrete = true;

When playing backward, the track_find_key method is called. It compares the values ​​here

if ((p_find_mode == FIND_MODE_APPROX && !Math::is_equal_approx(vt->values[k].time, p_time)) || (p_find_mode == FIND_MODE_EXACT && vt->values[k].time != p_time)) {
return -1;
}

and due to the fact that our position 6 has a time of 0.6, and not 1, it returns -1, which is why seek does not happen.

pi.is_external_seeking = true;
} else {
pi.is_external_seeking = !p_started;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is valid it should just be:

pi.is_external_seeking = backwards || !p_started;

No need for two blocks and much easier to read

@Nazarwadim Nazarwadim closed this Jun 9, 2024
@AThousandShips AThousandShips removed this from the 4.3 milestone Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Playing backwards discrete animation will begin with the first keyframe
4 participants